﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace WebApplication1
{
    public partial class ImageGallery : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();
            System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter();

            byte[] arrContent;

            

            string strSql;

            //strSql = "Select * from imgTable Where imgId= " + Request.QueryString["ID"];
            strSql = "Select * from imgTable ";

            String connString = @"Data Source=.\SQLEXPRESS;AttachDbFilename='C:\Ashwin\Source Codes\FullPageImageGallery\FullPageImageGallery\WebApplication1\App_Data\imgDB.mdf';Integrated Security=True;User Instance=True";

            da = new System.Data.SqlClient.SqlDataAdapter(strSql, connString);

            da.Fill(ds);

            if (ds.Tables[0].Rows.Count > 0)
            {
                this.ImgGalleryPH.Controls.Add(new LiteralControl("<div class='album'>"));
                for (int i = 0; i < ds.Tables[0].Rows.Count - 1; i++)
                {
                    this.ImgGalleryPH.Controls.Add(new LiteralControl("<div class='content'>"));
                    this.ImgGalleryPH.Controls.Add(new LiteralControl("<img src='imgGrab.aspx?id='" + ds.Tables[0].Rows[i] +" '/>"));
                    this.ImgGalleryPH.Controls.Add(new LiteralControl("</div>"));
                }
                this.ImgGalleryPH.Controls.Add(new LiteralControl("</div>"));
            }
        }
    }
}
